# Maintainer:  Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Maintainer:  Christian Hesse <mail@eworm.de>
# Contributor: Jon Eyolfson <jon@eyolfson.com>

pkgname=gitolite
pkgver=3.6.13
pkgrel=1
pkgdesc='An access control layer on top of git'
url='https://github.com/sitaramc/gitolite'
arch=('any')
license=('GPL2')
depends=('git' 'perl' 'openssh')
optdepends=('perl-json: json output')
source=("${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz"
        '0001-perl-sys-hostname.patch'
        'gitolite-sysusers.conf'
        'gitolite-tmpfiles.conf')
sha256sums=('b8ebd9f0ad89d1d7494da37883636f9475ef254cd018c8a54d21e678f4bf2b2a'
            '60775fcf967599ba2d48cdb21591a3150c7314f74e50579b040fc6bc05f0325f'
            '5e4f3aaa406c25fcd88fffaee74ea4878cecf1dd8c777456e4416caf35292dbf'
            '5682190c639618cd4744d3ae193425df1044dde4fb36acf03fc4d20423eeb10c')

prepare() {
  cd "${pkgname}-${pkgver}"

  echo "${pkgver}" > src/VERSION

  patch -Np1 < ../0001-perl-sys-hostname.patch
}

package() {
  # create directories
  install -d "${pkgdir}"/usr/{bin,lib/gitolite}

  # install files and create symlink
  cp -a "${pkgname}-${pkgver}"/src/* "${pkgdir}"/usr/lib/gitolite
  ln -s /usr/lib/gitolite/gitolite "${pkgdir}"/usr/bin/

  # sysusers and tmpfiles files
  install -D -m 0644 "${srcdir}"/gitolite-sysusers.conf "${pkgdir}"/usr/lib/sysusers.d/gitolite.conf
  install -D -m 0644 "${srcdir}"/gitolite-tmpfiles.conf "${pkgdir}"/usr/lib/tmpfiles.d/gitolite.conf
}
